package com.zenghus.template;

public class LoginTests {
    public static void main(String[] args) {
        String loginType="QQ";
        String username="";
        String password="";
        Login login=getLogin(loginType,username,password);
        login.userLogin();
        if(login.isLoginSuccess){
            System.out.println("登录成功：");
            System.out.println("用户唯一标识："+login.userData.get("identifier"));
            System.out.println("用户登录方式："+login.userData.get("loginType"));
        }else{
            System.out.println("提醒用户登录失败");
        }
    }

    /**
     * 简单工厂模式
     * @param loginType
     * @param username
     * @param password
     * @return
     */
    public static Login getLogin(String loginType,String username,String password){
        if(loginType.equals("QQ")){
            return new QQLogin(username,password);
        }else if(loginType.equals("BaiDu")){
            return new BaiDuLogin(username,password);
        }else{
            return null;
        }
    }
}
